package 测试;

import java.util.*;

public class Notepad {
	private LinkedList<Struct> list = new LinkedList<Struct>();
	Scanner s = new Scanner(System.in);

	// 增 add
	void list_Add() {
		String st = new String();
		while (!st.equals("#")) {
			Struct p = new Struct();
			System.out.println("输入日期");
			p.date = s.next();
			System.out.println("输入内容");
			p.str = s.next();
			list.add(p);
			System.out.println("输入任意继续     输入#结束 .....");
			st = s.next();
		}
		System.out.println("增加完成");
	}

	// 删 Delete
	void list_Delete() {
		// 按日期删除
		System.out.println("输入删除的日期");
		String str = s.next();

		Iterator<Struct> it = list.iterator();
		while (it.hasNext()) {
			Struct L;
			L = it.next();
			if (L.date.equals(str)) {
				list.remove(L);
				System.out.println("删除成功");
				return;
			}
		}
		System.out.println("删除错误");
	}

	// 改 change
	void list_Change() {
		// 按日期改
		System.out.println("输入要修改的日期");
		String str = s.next();
		Iterator<Struct> it = list.iterator();
		while (it.hasNext()) {
			Struct L;
			L = it.next();
			if (L.date.equals(str)) {
				Struct p = new Struct();
				p.date = L.date;
				System.out.println("输入修改的内容");
				p.str = s.next();
				list.set(list.indexOf(L), p);
				return;
			}
		}
		System.out.println("修改错误");
	}

	// 查
	void list_lookup() {
		System.out.println("输入要查找的日期");
		String str = s.next();
		Iterator<Struct> it = list.iterator();
		while (it.hasNext()) {
			Struct L;
			L = it.next();
			if (L.date.equals(str)) {
				System.out.println(L.date);
				System.out.println(L.str);
				return;
			}
		}
		System.out.println("查找错误");

	}

	// 遍历全部
	void list_Ergodic() {
		Iterator<Struct> it = list.iterator();
		while (it.hasNext()) {
			Struct L;
			L = it.next();
			System.out.println(L.date);
			System.out.println(L.str);

		}

	}

}
